// 配置路由的地方
import Vue from 'vue';
import VueRouter from 'vue-router';

// 使用插件
Vue.use(VueRouter);

// 引入路由组件
import Home from '@/pages/Home/index.vue';
import Search from '@/pages/Search/index.vue';
import Login from '@/pages/Login/index.vue';
import Register from '@/pages/Register/index.vue';

// 配置路由
export default new VueRouter({
  // 配置路由
  routes: [
    {
      name: 'home',
      path: '/home',
      component: Home,
      meta: { isShowFooter: true },
    },
    {
      name: 'search',
      path: '/search/:keyWord?',
      component: Search,
      meta: { isShowFooter: true },
    },
    {
      name: 'login',
      path: '/login',
      component: Login,
      meta: { isShowFooter: false },
    },
    {
      name: 'register',
      path: '/register',
      component: Register,
      meta: { isShowFooter: false },
    },

    // 重定向, 在项目跑起来的时候, 访问/, 立马让他定向到首页
    {
      path: '/',
      redirect: '/home',
    },
  ],
});
